function ValidateUtil() {

}

/**
 * 校验手机号
 * @param {Object} input 输入值
 * @return {TypeName}
 */
ValidateUtil.prototype.isCellphone = function(input) {
	var re = new RegExp("^[1][34578][0-9]{9}$");
    if (re.test(input)) return true;
    return false;
}

/**
 * 校验固定电话
 * @param {Object} input 输入值
 * @return {TypeName}
 */
ValidateUtil.prototype.isTelephone = function(input) {
	var re = new RegExp("^(\d{3}|\d{4})-\d{8}$");
    if (re.test(input)) return true;
    return false;
}

/**
 * 校验中文
 * @param {Object} input 输入值
 * @return {TypeName} 
 */
ValidateUtil.prototype.isChinese = function(input) {
	var re = new RegExp("^[\u4e00-\u9fa5]+$");
    if (re.test(input)) return true;
    return false;
}

/**
 * 校验字母、数字或下划线
 * @param {Object} input 输入值
 * @return {TypeName} 
 */
ValidateUtil.prototype.isLetterAndNumber = function(input) {
	var re = new RegExp("^[0-9a-zA-Z\_]+$");
    if (re.test(input)) return true;
    return false;
}

/**
 * 校验组织机构代码
 * @param {Object} input 输入值
 * @return {TypeName} 
 */
ValidateUtil.prototype.isOrganCode = function(input) {
	var ws = new Array(3, 7, 9, 10, 5, 8, 4, 2);
	var str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var re = new RegExp("^([0-9A-Z]){8}-[0-9|X]$");
	if (!re.test(input)){
		return false;
	}
	input = input.replace("-", "");	
	var sum = 0;
	for (var i = 0; i < 8; i++) {
		sum += str.indexOf(input.charAt(i)) * ws[i];
	}
	var c9 = 11 - (sum % 11);
	var sc9 = c9;
	if (11 == c9) {
		sc9 = "0";
	} else if (10 == c9) {
		sc9 = "X";
	}
    return sc9 == input.charAt(8);
}

/**
 * 校验社会信用代码
 * @param {Object} input 输入值
 * @return {TypeName} 
 */
ValidateUtil.prototype.isSocialCredit = function(input) {
	var ws = new Array(1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28);
	var str = "0123456789ABCDEFGHJKLMNPQRTUWXY";
	var re = new RegExp("^[1|5|9|Y][1-3|9][0-9]{6}[0-9A-H|J-N|P-R|T|U|W-Y]{10}$");
	if (!re.test(input)){
		return false;
	}
	var areaRe = new RegExp("^1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|71|8[1-2]");
	if (!areaRe.test(input.substring(2, 4))){
		return false;
	}
	if(!ValidateUtil.prototype.isOrganCode(input.substring(8, 16) + "-" + input.substring(16, 17))){
		return false;
	}
	var sum = 0;
	for (var i = 0; i < 17; i++) {
		sum += str.indexOf(input.charAt(i)) * ws[i];
	}
	var c18 = 31 - (sum % 31);
	if (c18 == 31) {
		c18 = 0;
	}
    return input.substring(17, 18) == str.charAt(c18);
}

/**
 * 校验身份证号
 * @param {Object} input 输入值
 * @return {TypeName} 
 */
ValidateUtil.prototype.isIdCard = function(input) {
	if(!input || input.length != 18){
		return false;
	}
	var valCodeArr = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4","3", "2");
	var wi = new Array("7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7", "9", "10", "5", "8", "4", "2");
	var re = new RegExp("^[0-9]+");
	if (!re.test(input.substring(0, 17))){
		return false;
	}
	var year = input.substring(6, 10);
	var month = input.substring(10, 12);
	var day = input.substring(12, 14);
	if(year < 1950 || year > new Date().getYear() + 1900){
		return false;
	}
	if(month < 1 || month > 12){
		return false;
	}
	var maxDay = DateUtil.prototype.getDays();
	if(day < 0 || day > maxDay){
		return false;
	}
	var areaRe = new RegExp("^1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|71|8[1-2]|91");
	if (!areaRe.test(input.substring(0, 2))){
		return false;
	}
	var totalmulAiWi = 0;
	for (var i = 0; i < 17; i++) {
		totalmulAiWi = totalmulAiWi + parseInt(input.charAt(i)) * parseInt(wi[i]);
	}
	var modValue = totalmulAiWi % 11;
	var strVerifyCode = valCodeArr[modValue];
	return input.substring(17, 18) == strVerifyCode;
}